package com.heima.behavior.controller.v1;

import com.heima.behavior.service.*;
import com.heima.model.behavior.dtos.*;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @作者 Azer
 * @创建日期 2021/11/27 14:57
 **/
@Api(tags = "behavior行为接口",value = "behavior行为接口")
@RestController
@RequestMapping("/api/v1")
public class APBehaviorController {

    @Autowired
    ApLikesBehaviorService apLikesBehaviorService;

    @Autowired
    ApReadBehaviorService apReadBehaviorService;

    @Autowired
    ApUnlikeBehaviorService apUnlikeBehaviorService;

    @Autowired
    ApCollectionBehaviorService apCollectionBehaviorService;

    @Autowired
    ApArticleBehaviorService apArticleBehaviorService;

    @ApiOperation(value = "点赞行为")
    @PostMapping("/likes_behavior")
    public ResponseResult load(@RequestBody @Validated LikesBehaviorDTO dto){
        return apLikesBehaviorService.like(dto);
    }

    @ApiOperation(value = "阅读行为")
    @PostMapping("/read_behavior")
    public ResponseResult read(@RequestBody @Validated ReadBehaviorDTO dto){
        return apReadBehaviorService.readBehavior(dto);
    }

    @ApiOperation(value = "不喜欢行为")
    @PostMapping("/un_likes_behavior")
    public ResponseResult unLike(@RequestBody @Validated UnLikesBehaviorDTO dto){
        return apUnlikeBehaviorService.unlikeBehavior(dto);
    }

    @ApiOperation(value = "收藏行为")
    @PostMapping("/collection_behavior")
    public ResponseResult collection(@RequestBody @Validated CollectionBehaviorDTO dto){
        return apCollectionBehaviorService.collectBehavior(dto);
    }

    @ApiOperation(value = "文章行为")
    @PostMapping("/article/load_article_behavior")
    public ResponseResult articleBehavior(@RequestBody @Validated ArticleBehaviorDTO dto){
        return apArticleBehaviorService.loadArticleBehavior(dto);
    }

}
